package com.cakin.javademo;

/**
 * @ClassName: TestDemo2
 * @Description: 赋值运算
 * @Date: 2020/6/13
 * @Author: cakin
 */
public class TestDemo2 {
    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        int c = 0;
        c = a + b;
        System.out.println("c = a + b = " + c ); // c = 30
        c += a ;
        System.out.println("c += a  = " + c ); // c = 40
        c -= a ;
        System.out.println("c -= a = " + c ); // c =30
        c *= a ;
        System.out.println("c *= a = " + c ); // c=300
        System.out.println("================================");
        a = 10;
        c = 15;
        c /= a ;
        System.out.println("c /= a = " + c ); // c = 1
        System.out.println("================================1");
        a = 10;
        c = 15;
        c %= a ;
        System.out.println("c %= a  = " + c ); // c = 5
        c <<= 2 ;
        System.out.println("c <<= 2 = " + c ); //c =20
        c >>= 2 ;
        System.out.println("c >>= 2 = " + c ); // c=5
        c >>= 2 ;
        System.out.println("c >>= 2 = " + c );  // c=1

        System.out.println("================================2");

        c &= a ;  // (0001)&(1010)  c = 0
        System.out.println("c &= a  = " + c );  // c =0(0000) a =1010
        c ^= a ;
        System.out.println("c ^= a   = " + c );  //c=1010
        c |= a ;
        System.out.println("c |= a   = " + c );  // c= 1010 c = 10



    }
}
